{// 引入标签库 }
<tagLib name="html" />
<include file="Public:header" />
<php>function get_status_text($v){return $v==1?'进行中':'已开奖';}</php>
<div style="height:10px;"></div>
<div style="margin:0 10px; width:390px; float:left;">
    <a href="#" onclick="location.reload()">刷新</a><br /><br />
    <table class="dataTable">
        <tr><th>节目名称：</th><td title="节目编号：{$xiacai.id}">{$xiacai.subject}</td></tr>
        <tr><th>节目简介：</th><td>{$xiacai.desc}</td></tr>
        <tr><th>开播时间提示：</th><td>{$xiacai.start_time_tip}</td></tr>
        <tr><th>主播ID：</th><td>{$xiacai.user_id}</td></tr>
    </table><br />
    <button class="btn btn-primary" id="btn-start" data-url="/mapi/index.php?ctl=video&act=add_video&cate_id=1&user_id={$xiacai.user_id}" data-xiacai_id="{$xiacai.id}">立即开播并获取推流地址</button>
    <div id="result-panel" style="margin-top:10px; line-height:21px;"></div>
</div>
<script>
    // 2017-11-6
    $('#btn-start').click(function () {
        if (!confirm('确定要开始直播吗?')) {
            return false;
        }
        var url = $(this).data('url');
        var xiacai_id = $(this).data('xiacai_id');
        $.post(url, function (result) {
            result = JSON.parse(result);
            console.log(result);
            if (result.status) {
                $.get('/mapi/index.php?ctl=video&act=video_cstatus&user_id={$xiacai.user_id}&room_id=' + result.room_id + '&status=1', function () {
                    location.href = '/m.php?m=Xiacai&a=play&video_id=' + result.room_id + '&xiacai_id=' + xiacai_id;
                });
            } else {
                alert(result.error);
            }
        });
        return false;
    })
</script>